package com.xj.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Tools {
    public static String getCurrentTime() {
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public static void calculateSyncExecutionTime(long startTime, long endTime) {
        long duration = endTime - startTime;
        if (duration < 1000) {
            System.out.println("任务执行耗时: " + duration + "ms");
        } else if (duration < 60000) {
            System.out.println("任务执行耗时: " + String.format("%.2f", duration / 1000.0) + "s");
        } else {
            System.out.println("任务执行耗时: " + String.format("%.2f", duration / 60000.0) + "min");
        }
    }
}